﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>用户登录</title>
        <link type="text/css" rel="Stylesheet" href="../../Content/logon.css" />
     <script type="text/javascript" language="javascript" src=' <%=Url.Content("~/Scripts/jquery-1.4.4.min.js") %>'></script>
    <script type="text/javascript" src='<%=Url.Content("~/Scripts/jquery.validate.js") %>'></script>
    <script language="javascript" type="text/javascript">
        $(function() {
            $("#userForm").validate({
                rules: {
                    userName: "required",
                    pwd: "required",
                    imgcode: "required"
                }
            });
        });
        function changeImg(t) {
            var a = $(t);
            $.ajax({
                datatype: "text",
                type: "Post",
                url: "../Admin/GetImgCode",
                success: function(data) {
                    if (data == "0") {
                        alert("对不起，发生未知错误，获取图片失败！请您稍后再试！");
                    } else {
                    a.siblings("#codeImg").attr("src", data);
                    }
                }
            });
        }
        function Login() {
            if ($("#userForm").validate().form()) {
            $.ajax({
                datatype: "text",
                type: "Post",
                url: "../Admin/Login",
                data:{
                    username:$("#userName").val(),
                    pwd:$("#pwd").val(),
                    code:$("#imgcode").val()
                    },
                success: function(data) {
                    if (data == "1") {
                        window.location.href = "../Admin/Index";
                    } else {
                        alert(data);
                    }
                }
            }); 
            }       
        }         
    </script>

</head>
<body>
    <div id="mainbody">
        <div id="upbody">
            <div id="header">
                <h3>
                    桂林二手房网后台管理</h3>
                <div id="upbg">
                    <div id="btmbg">
                        <form id="userForm" runat="server">
                        <div id="logonbar">
                        </div>
                        <table class="formTable">
                            <caption>
                                用户登录</caption>
                            <tr>
                                <td class="label">
                                    用户名：
                                </td>
                                <td>
                                    <input type="text" class="txt" id="userName" name="userName" style="width: 120px" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    密码：
                                </td>
                                <td>
                                    <input type="password" id="pwd" name="pwd" style="width: 120px" />
                                </td>
                            </tr>
                            <tr>
                                <td class="label">
                                    验证码：
                                </td>
                                <td>
                                    <input type="text" id="imgcode" name="imgcode" style="width: 80px" /><img id="codeImg" src='<%=ViewData["imgpage"] %>' alt="输入认证码" /><a href="javascript:void" onclick="changeImg(this)">看不清</a>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2" class="label" style="text-align: center">
                                    <input type="button"  onclick="Login()" value="登录" />
                                </td>
                            </tr>
                        </table>
                        <p>
                        </p>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div id="btmbody">
            <p>
                Copyright©2009-2011 桂林二手房 All Rights Reserved.</p>
            <p>
                Design And Coding By huangjingwen huanghan zhoushaoshui</p>
        </div>
    </div>
</body>
</html>
